import { fileURLToPath, URL } from 'node:url'

import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { defineConfig } from 'vite'
import eslint from 'vite-plugin-eslint'
import PurgeIcons from 'vite-plugin-purge-icons'
import vueDevTools from 'vite-plugin-vue-devtools'

// https://vitejs.dev/configk/
export default defineConfig({
  plugins: [
    eslint({
      failOnWarning: false
    }),
    vue(),
    vueJsx(),
    vueDevTools(
      // {launchEditor:"D:/code/trae-launcher.sh"},
      // {launchEditor:"trae"}
    ),
    PurgeIcons()
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@use "@/styles/element/index.scss" as *;`,
        api: 'modern-compiler'
      }
    }
  },
  server: {
    proxy: {
      // '/api/role/v2/listResourceIds': {
      //   target: 'http://127.0.0.1:4523/m1/5040115-4700668-default',
      //   changeOrigin: true
      // },
      '/api': {
        target: 'http://192.168.18.164:8081 ',
        changeOrigin: true
      },
      '/rtc': {
        target: 'http://192.168.18.164:1985',
        changeOrigin: true
      },
      '/websocket': {
        target: 'ws://192.168.18.164:8081',
        ws: true
      },
      '/tiles': {
        target: 'http://192.168.18.164:3000',
        changeOrigin: true
      }
    }
  }
})
